package ai.mspbots.poc.core;

import lombok.Data;

@Data
public class Response<T> {

    private int code;

    private String message;

    private T data;

    public static <T> Response<T> success(T data) {
        Response<T> response = new Response<>();
        response.setCode(20000);
        response.setMessage("success");
        response.setData(data);
        return response;
    }

    public static Response<Void> ok(String message) {
        Response<java.lang.Void> response = new Response<>();
        response.setCode(20000);
        response.setMessage(message);
        response.setData(null);
        return response;
    }

    public static Response<Void> error(String message) {
        Response<java.lang.Void> response = new Response<>();
        response.setCode(-1);
        response.setMessage(message);
        response.setData(null);
        return response;
    }

    public static <T> Response<T> error(String message, T data) {
        Response<T> response = new Response<>();
        response.setCode(-1);
        response.setMessage(message);
        response.setData(data);
        return response;
    }

    public static Object build(Object body) {
        Response<Object> response = new Response<>();
        response.setCode(20000);
        response.setMessage("success");
        response.setData(body);
        return response;
    }
}
